Component({
  options: {
    styleIsolation: 'shared'
  },
  /**
   * 组件的属性列表
   */
  properties: {
    noCarReason: {
      type: String,
      value: ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    autoSize: {
      maxHeight: '400rpx',
      minHeight: '136rpx'
    },
    reason: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    reasonChange(e) {
      this.setData({
        noCarReason: e.detail
      })
    },
    showPopup() {
      this.setData({
        show: true
      })
    },
    clickHandle() {
      if (this.data.noCarReason.trim() === '') {
        wx.showToast({
          title: '无需物流原因不能空',
          icon: 'none'
        })
        return
      }

      this.setData(
        {
          show: false
        },
        () => {
          this.triggerEvent('noCarSubmit', this.data.noCarReason)
        }
      )
    },
    closeHandle() {
      this.setData({
        show: false
      })
    }
  },
  lifetimes: {
    attached() {
      this.setData({
        noCarReason: this.data.noCarReason
      })
    }
  }
})
